package org.bikelab.se3.rdf.reader;

import java.io.ByteArrayInputStream;
import java.util.Iterator;

import org.semanticweb.yars.nx.Literal;
import org.semanticweb.yars.nx.Node;
import org.semanticweb.yars.nx.Resource;
import org.semanticweb.yars.nx.parser.NxParser;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Statement;

public class NqLineReader implements RdfReader {
	Iterator<Node[]> nodeIter;
	
	@Override
	public boolean hasNext() {
		if(nodeIter == null) {
			return false;
		}
		return nodeIter.hasNext();
	}

	@Override
	public Node[] next() {
		// TODO Auto-generated method stub
		return nodeIter.next();
	}

	@Override
	public void remove() {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void read(String line) throws RdfReaderException {
		line = line.trim();
		if(line.isEmpty()) {
		} else {
			try {
				nodeIter = new NxParser(new ByteArrayInputStream(line.getBytes()), false);
			} catch(Exception e) {
				throw new RdfReaderException();
			}
		}
	}
}
